home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / pluginy Firefox / 9536 / 9536.xpi / chrome / commentsbar_ff.jar / content / commentsbar_ff / bubble.js < prev    next >
Text File  |  2009-03-25  |  4KB  |  161 lines

  1. var type="1";
  2. var src; 
  3. var windframe;
  4. var mainwindow;
  5. var name;
  6. var tool;
  7. var isDragged = false;
  8.  
  9. window.onload = function () {
  10. try{
  11. window.sizeToContent ();
  12. var wind = document.getElementById('bubble');
  13. var x=toolbar_load_pref(name + "_screenx" ,"");
  14. var y=toolbar_load_pref(name + "_screeny" ,"");
  15.  
  16. src=toolbar_load_pref(name + "_src" ,"");
  17. var width=toolbar_load_pref(name + "_width" ,"");
  18. var height=toolbar_load_pref(name + "_height" ,"");
  19. type=toolbar_load_pref(name + "_type" ,"");
  20. var scroll=toolbar_load_pref(name + "_scroll" ,"");
  21.  
  22. wind.setAttribute('screenX',x);
  23. wind.setAttribute('screenY',y);
  24. wind.setAttribute('width',width);
  25. wind.setAttribute('height',height);
  26.  
  27. windframe= document.getElementById('frame');
  28. windframe.setAttribute('type',"content-targetable");
  29. //windframe.setAttribute('disablehistory',"true");
  30. windframe.setAttribute('src',src);
  31. windframe.setAttribute('height',height);
  32.  
  33. if (scroll=="0") windframe.setAttribute('style',"border: 0px solid ; margin: 0px;padding: 0px;");
  34.  
  35. if (windframe.contentWindow.DocumentComplete) windframe.contentWindow.DocumentComplete(tool);
  36. if (windframe.contentWindow.ToolBarInit) windframe.contentWindow.ToolBarInit(tool);
  37.  
  38. windframe.addEventListener("load", loadframe, true);
  39.  
  40. }catch(e){alert(e);}
  41. }
  42.  
  43.  
  44.  
  45. function startdelay ()
  46. {
  47. src=windframe.contentDocument.location;
  48. if (type=="0") delay();
  49. }
  50.  
  51. function delay ()
  52. {
  53. try{
  54.  
  55. var href=windframe.contentDocument.location;
  56. var temp=''+href;
  57. var offset=0;
  58. offset=temp.indexOf('inbanner',0);
  59.     if (href==src ||  offset != -1)
  60.         {
  61.         setTimeout ('delay();', 10);
  62.         return;
  63.     }
  64. //toolbar_pref( "newlocation", windframe.contentDocument.location );
  65. mainwindow._content.document.location=windframe.contentDocument.location;
  66. //alert(windframe.contentDocument.location);
  67. window.close();
  68. }catch(e){alert(e);}
  69. }
  70.  
  71.  
  72. function loadframe()
  73. {
  74. try{
  75. if (windframe.contentWindow.DocumentComplete) windframe.contentWindow.DocumentComplete(tool);
  76. if (windframe.contentWindow.ToolBarInit) windframe.contentWindow.ToolBarInit(tool);
  77. setTimeout(startdelay,1000);
  78. }catch(e){alert(e);}
  79. }
  80.  
  81.  
  82. function toolbar_getPrefBranch()
  83. {
  84. try {
  85.     var prefService = Components.classes["@mozilla.org/preferences-service;1"]
  86.                         .getService(Components.interfaces.nsIPrefService);
  87.     return prefService.getBranch(null);
  88. } catch(e) {alert(e);}
  89. }
  90.  
  91. function toolbar_pref(prefName, value)
  92. {
  93. try {
  94.     value=escape(value);
  95.     var prefBranch = toolbar_getPrefBranch();
  96.     if (typeof(value) == "number")
  97.         prefBranch.setIntPref(prefName, value);
  98.     else if (typeof value == "string")
  99.         prefBranch.setCharPref(prefName, value);
  100.     else if (typeof value == "boolean")
  101.         prefBranch.setBoolPref(prefName, value);
  102. } catch(e) {alert(e);}
  103. }
  104.  
  105. function toolbar_defaultPref(prefName, value)
  106. {
  107. try {
  108.     value=escape(value);
  109.     var prefService = Components.classes["@mozilla.org/preferences-service;1"]
  110.                         .getService(Components.interfaces.nsIPrefService);
  111.     var prefBranch = prefService.getDefaultBranch(null);
  112.     if (typeof value == "string")
  113.         prefBranch.setCharPref(prefName, value);
  114.     else if (typeof value == "number")
  115.         prefBranch.setIntPref(prefName, value);
  116.     else if (typeof value == "boolean")
  117.         prefBranch.setBoolPref(prefName, value);
  118. } catch(e) {alert(e);}
  119. }
  120.  
  121. function toolbar_getPref(prefName)
  122. {
  123. try {
  124.     var prefBranch = toolbar_getPrefBranch();
  125.     switch (prefBranch.getPrefType(prefName))
  126.     {
  127.         case prefBranch.PREF_STRING:
  128.             return unescape(prefBranch.getCharPref(prefName));
  129.         case prefBranch.PREF_INT:
  130.             return prefBranch.getIntPref(prefName);
  131.         case prefBranch.PREF_BOOL:
  132.             return prefBranch.getBoolPref(prefName);
  133.         default:
  134.             return null;
  135.     }
  136. } catch(e) {alert(e);}
  137.     return null;
  138. }
  139.  
  140. function toolbar_clearPref(prefName)
  141. {
  142. try {
  143.     var prefBranch = toolbar_getPrefBranch();
  144.     toolbar_prefBranch.clearUserPref(prefName);
  145. } catch(e) {alert(e);}
  146. }
  147.  
  148. function toolbar_load_pref(pName, defValue)
  149. {
  150. try {
  151.     var val = toolbar_getPref(pName);
  152.     if( val == null )
  153.     {
  154.         val = defValue;
  155.         toolbar_defaultPref(pName, val);
  156.     }
  157.     return val;
  158. } catch(e) {alert(e);}
  159. }
  160.  
  161.